/**
 * Created by Egan on 2015/1/20.
 */
module catgame{

    export class FailPanel extends egret.Sprite{

        private tap_textfeild:egret.TextField;
        private rank_textfeild:egret.TextField;
        private share_btn:egret.Bitmap;
        private replay_btn:egret.Bitmap;
        private mao2_btn:egret.Bitmap;

        public constructor(){
            super();

            var bg=this.createBitmapByName("failed_bg");//失败面板背景

            this.tap_textfeild=new egret.TextField();
            this.tap_textfeild.width=400;
            this.tap_textfeild.textColor=0xff0000;
            this.tap_textfeild.textAlign=egret.HorizontalAlign.CENTER;
            this.tap_textfeild.text="你没有抓住神经猫";
            this.tap_textfeild.size=22;
            this.tap_textfeild.x=20;
            this.tap_textfeild.y=190;

            this.rank_textfeild=new egret.TextField();
            this.rank_textfeild.width=400;
            this.rank_textfeild.textColor=0xffffff;
            this.rank_textfeild.textAlign=egret.HorizontalAlign.CENTER;
            this.rank_textfeild.text="无名氏";
            this.rank_textfeild.size=22;
            this.rank_textfeild.stroke=2;
            this.rank_textfeild.x=20;
            this.rank_textfeild.y=230;

            this.share_btn=this.createBitmapByName("share_btn");
            this.share_btn.x=10;
            this.share_btn.y=bg.height+20;
            this.share_btn.touchEnabled=true;
            this.share_btn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.doShare,this);

            this.replay_btn=this.createBitmapByName("replay_btn");
            this.replay_btn.x=220;
            this.replay_btn.y=bg.height+20;
            this.replay_btn.touchEnabled=true;
            this.replay_btn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.doRepaly,this);

            this.mao2_btn=this.createBitmapByName("mao2");
            this.mao2_btn.x=90;
            this.mao2_btn.y=bg.height-80;
            this.mao2_btn.touchEnabled=true;
            this.mao2_btn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.doJump,this);

            this.addChild(bg);
            this.addChild(this.tap_textfeild);
            this.addChild(this.rank_textfeild);
            this.addChild(this.share_btn);
            this.addChild(this.replay_btn);
            this.addChild(this.mao2_btn);
        }

        public doShare(e:egret.TouchEvent):void{
            console.log("doShare");
            this.dispatchEventWith("shareEvent");
        }

        public doRepaly(e:egret.TouchEvent):void{
            console.log("doRepaly");
            this.dispatchEventWith("replayEvent");
        }

        public doJump(e:egret.TouchEvent):void{
            console.log("doJump");
        }

        private createBitmapByName(name:string):egret.Bitmap{
            var result:egret.Bitmap=new egret.Bitmap();
            var texture:egret.Texture=RES.getRes(name);
            result.texture=texture;

            return result;
        }

    }

}